#!/data/Software/mydan/perl/bin/perl -I/data/Software/mydan/JOB/lib -I/data/Software/mydan/JOB/private/lib
use strict;
use warnings;
use Code;
use YAML::XS;
use FindBin qw( $RealBin );
use File::Basename;

$| ++;

=head1 SYNOPSIS

    db => $mysql,
    projectid => 1,
    node => foo,
    vv => [ k1, v1, k2, v2, ..]

    logs => 日志对象


=cut

return sub
{
    my %param = @_;
    my ( $db, $projectid, $node, $vv, $logs )
        = @param{qw(db projectid node vv logs )};
    $logs = Logs->new( 'code.vv' ) unless $logs;
    while( @$vv )
    {
        my ( $k, $v ) = splice @$vv, 0, 2;
        eval{ $db->execute( "replace into vv (`projectid`,`node`,`name`,`value`)values('$projectid','$node','$k','$v')") };
        $logs->die( "vv code write db fail :$@" ) if $@;
    }
    return;
}
